package com.wondersgroup.fjzlpt.org.controller.view.jgqy.lshgl;

import java.util.Iterator;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.quick.framework.util.QuickPrincipalUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.quick.framework.boot.web.utils.RequestUtils;
import com.quick.framework.boot.web.wapper.QuickPrincipal;
import com.wondersgroup.fjzlpt.org.dao.inter.fwxx.FwxxDAO;
import com.wondersgroup.fjzlpt.org.dao.inter.jgqy.blxx.BlxxDAO;
import com.wondersgroup.fjzlpt.org.dao.inter.jgqy.fwgl.FwglYljgDAO;
import com.wondersgroup.fjzlpt.org.dao.inter.jgqy.fwgl.LyjlDAO;
import com.wondersgroup.fjzlpt.org.dao.inter.jgqy.fwgl.TljlDAO;
import com.wondersgroup.fjzlpt.org.dao.inter.jgqy.qysq.QysqDAO;
import com.wondersgroup.fjzlpt.org.service.inter.jgqy.fwgl.FwglService;
import com.wondersgroup.fjzlpt.org.service.inter.jgqy.jrylt.JryltService;
import com.wondersgroup.fjzlpt.org.service.inter.jgqy.lshgl.LshglService;

@Controller
@RequestMapping("lshgl")
public class LshglController {
	
	@Autowired
	private LshglService lshglService;
	
	@Autowired
	private JryltService jryltService;
	
	@RequestMapping("/index.html")
	public String index(HttpServletRequest request)
	{
        JSONObject json = new JSONObject();
        json.put("PTJGID", QuickPrincipalUtils.getPtjgID(request));
        request.setAttribute("userInfo", json);
		return "jgqy/lshgl/index";
	}
	
	@RequestMapping("/manager.html")
	public String manager(HttpServletRequest request)
	{
        JSONObject json = new JSONObject();
        json.put("PTJGID", QuickPrincipalUtils.getPtjgID(request));
        json.put("XM", QuickPrincipalUtils.getUserinfoByKey(request , "XM"));
        json.put("USERID", QuickPrincipalUtils.getUserID(request));
        request.setAttribute("userInfo", json);
		return "jgqy/lshgl/manager";
	}
	
	@RequestMapping("/detail.html")
	public String detail(HttpServletRequest request)
	{
		Map<String, String> map = RequestUtils.GetParameterMap(request);
		if(map.containsKey("LSHGLID")){
			map.put("pageSize", "1");
			map.put("pageNumber", "1");
			JSONObject jo = lshglService.queryPage(map);
			jo = (JSONObject) (jo.getJSONArray("rows")).get(0);
			String lsxms = lshglService.queryLs(map);
			jo.put("LSXMS", lsxms);
			request.setAttribute("lshglxx", jo);
			/**获取签约机构信息*/
			map.put("YLTLX", jo.getString("YLTLX"));
			map.put("YLTID", jo.getString("YLTID"));
			JSONArray ja = jryltService.queryQyJg(map);
			request.setAttribute("qyjgxx", ja);
		}
		return "jgqy/lshgl/detail";
	}
	
	@RequestMapping("/yljgry.html")
	public String yljgry(HttpServletRequest request)
	{
		return "jgqy/lshgl/yljgry";
	}
	
}
